# Stage 1: build
FROM node:22-alpine AS builder
WORKDIR /app

# 安装构建依赖（复制 package-lock/package.json 以利用缓存）
COPY package*.json ./
RUN npm ci

# 复制源代码并构建
COPY . .
RUN npm run build -- --preset=node-server

# Stage 2: production image
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production

# 复制构建产物（Nuxt3 默认输出 .output）
COPY --from=builder /app/.output ./.output

EXPOSE 3000

# 启动命令（Nuxt3）
CMD ["node", ".output/server/index.mjs"]
